package com.songlanyun.modules.jst.service.impl;

import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.songlanyun.common.utils.DateUtils;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.Query;
import com.songlanyun.modules.jst.dao.jstDao;
import com.songlanyun.modules.jst.entiy.JstRecord;
import com.songlanyun.modules.jst.service.JstOrderRecordService;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Map;


@Service("JstOrderRecordService")
public class JstOrderRecordServiceImpl extends ServiceImpl<jstDao, JstRecord> implements JstOrderRecordService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Date startTime = MapUtil.getDate(params, "startTime");
        System.out.println("startTime:"+startTime);
        if(ObjectUtil.isNotNull(startTime))
        {
            params.put("st",startTime.getTime());
            System.err.println("startTime.getTime:"+startTime.getTime());
        }
        System.out.println("params:"+params.toString());
        Date endTime = MapUtil.getDate(params, "endTime");
        System.out.println("endTime:"+endTime);
        if(ObjectUtil.isNotNull(endTime))
        {
            endTime = DateUtils.addDateDays(endTime,1);
            params.put("et", endTime.getTime());
            System.err.println("endTime.getTime:"+ endTime.getTime());

        }
        IPage<JstRecord> page = this.baseMapper.queryJstOrderRecordPage(new Query<JstRecord>().getPage(params), params);
        return new PageUtils(page);
    }
}
